<template>
  <a-col class="gutter-row" :span="span">
    <a-form-item :name="name" :autoLink="autoLink">
      <div class="search-item" :class="{'search-item-button': button}">
        <label v-if="label" :style="[labelWidthStyle]">{{ label }}：</label>
        <div><slot /></div>
      </div>
    </a-form-item>
  </a-col>
</template>
<script setup>
import { ref, computed } from 'vue'
/**
 * props
 */
const props = defineProps({
  label: {
    type: String,
    default: ''
  },
  labelWidth: {
    type: String,
    default: ''
  },
  button: Boolean,
  name: {
    type: String,
    default: ''
  },
  span: {
    type: Number,
    default: 4
  },
  autoLink: {
    type: Boolean,
    default: true
  }
})
/**
 * 表单对象
 */
const searchFormRef = ref(null)

const reset = () => {}

const labelWidthStyle = computed(() => {
  return props.labelWidth ? {width: props.labelWidth} : {}
})

</script>
<style lang="scss" scoped>
.search-item {
  display: flex;
  align-items: center;
  label { width: 70px; }
  > div {
    flex: 1;
    width: 0;
  }
}
.search-item-button {
  label { display: none; }
}
</style>
